<template>
	<view class="banner">
		<!-- 热搜 -->
		<view class="content">
			<view class="hot_word">
				<view class="hot_search ">
					热搜
				</view>
				<view class="hot_box">
					<view class="item" v-for="item in HotSarch" :key="item._id">
						{{ item.name }}
					</view>
				</view>
			</view>
		</view>
		<!-- 海报 -->
		<view class="swiperbox">
			<swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
				<swiper-item v-for="item in BannerList" :key="item._id" >
					<image :src="item.url" mode="" @click="changePath(item.link)" ></image>
				</swiper-item>
				
			</swiper>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				HotSarch: [],
				autoplay: true,
				duration: 500,
				interval: 3000,
				indicatorDots: false,
				BannerList: [],
			}
		},
		mounted() {
			this.getHotSearch()
			this.getBanner()
		},
		methods: {
			// 获取热搜
			async getHotSearch() {
				let res = await this.$Request("/indexpage/showHotSearch", "")
				let code = res.data.code
				if(code == 200) {
					this.HotSarch = res.data.data
				}
			},
			// 获取海报轮播图
			async getBanner() {
				let res = await this.$Request("/indexpage/showBanner", "")
				let code = res.data.code
				if(code == 200) {
					this.BannerList = res.data.data
				}
			},
			// 点击海报跳转
			changePath( path ) {
				console.log(path);
			}
		},
	}
</script>

<style scoped lang="scss">
	.banner {
		width: 100%;
		box-sizing: border-box;
		margin-top: 100rpx;
		.content {
			width: 100%;
			.hot_word {
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: center;
				padding: 10rpx;
				box-sizing: border-box;
				font-size: 26rpx;
				overflow: hidden;
				.hot_search {
					width: 100rpx;
					text-align: center;
					padding: 10rpx;
					color: red;
					font-weight: bold;
				}
				.hot_box {
					flex: 1;
					display: flex;
					flex-wrap: wrap;
					align-items: center;
					.item {
						margin: 0 10rpx ;
						flex: 1;
						text-align: center;
						padding: 10rpx;
						margin: 10rpx;
						border-radius: 20rpx;
						background-color: pink;
						color: #fff;
					}
				}
			}
		}
		.swiperbox {
			width: 680rpx;
			height: 200rpx;
			box-sizing: border-box;
			margin:  0 auto;
			border: 1px solid #aaa;
			border-radius: 30rpx;
			overflow: hidden;
			image {
				width: 680rpx;
				height: 200rpx;
			}
		}
	}
</style>
